<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('添加打分人员')"/>
    <th:block th:include="include :: datetimepicker-css"/>
    <th:block th:include="include :: select2-css"/>
    <th:block th:include="include :: bootstrap-select-css"/>
</head>
<style>
    input::-webkit-outer-spin-button, input::-webkit-inner-spin-button {
        -webkit-appearance: none;
    }

    input[type="number"] {
        -moz-appearance: textfield;
    }

</style>
<body>
<div class="wrapper wrapper-content animated fadeInRight ibox-content" id="dv">
    <form class="form-horizontal m" id="form-acvEmpManage-add" AUTOCOMPLETE="OFF">
        <h4 class="form-header h4">基本信息</h4>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">姓名：</label>
                    <div class="col-sm-8">
                        <input id="userName" name="userName" class="form-control" type="text"
                               placeholder="姓名" required />
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">登录用户名：</label>
                    <div class="col-sm-8">
                        <input id="loginName" name="loginName" class="form-control" type="text"
                               placeholder="登录用户名" required />
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">二级部门：</label>
                    <div class="col-sm-8">
                        <select id="deptId" name="deptId" onchange="getTertiaryDept()" class="form-control">
                            <option value="">请选择</option>
                            <option th:each="dep:${secondaryDeptList}" th:value="${dep.deptId }"
                                    th:text="${dep.deptName }"></option>
                        </select>
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">三级部门：</label>
                    <div class="col-sm-8">
                        <select id="tertiaryDeptId" name="tertiaryDeptId" class="form-control">
                            <option value="">请选择</option>

                        </select>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: datetimepicker-js"/>
<th:block th:include="include :: select2-js"/>

<script type="text/javascript">
    var prefix = ctx + 'acvEmpManage';

    $(function () {
    })


    function submitHandler() {

        if ($.validate.form()) {
            if($("#deptId").val() == ""){
                $.modal.alertWarning('请选择二级部门!');
                return;
            }

            var data = $("#form-acvEmpManage-add").serializeArray();
            $.operate.save(prefix + "/addExamine", data);
        }
    }

    function getTertiaryDept(){
        var deptId = $("#deptId").val();
        var html = "";

        $.ajax({
            async: false,
            url: ctx + "acvEmpManage/getTertiaryDept",
            data: {
                "deptId": deptId
            },
            type: "post",
            dataType: "json",
            success: function (data) {
                $("#tertiaryDeptId").empty();
                var arry = data;
                html += "<option value=''>请选择</option>";
                for (var i = 0; i < arry.length; i++) {
                    html += "<option value='"
                        + arry[i].deptId
                        + "'>"
                        + arry[i].deptName
                        + "</option>";
                }
                $("#tertiaryDeptId").append(html);
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                alert("错误,请联系管理员,错误信息:" + textStatus);
            }
        });
    }

</script>

</body>
</html>